package com.android.lovingpet.home.view;


import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.android.lovingpet.R;
import com.android.lovingpet.community.PageAdapter;
import com.android.lovingpet.community.post.PostActivity;



public class CommunityFragment extends Fragment/* implements View.OnClickListener*/ {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_community, container, false);
        //((TextView)view.findViewById(R.id.tv_title)).setText("社区");

        //view.findViewById(R.id.cv_search).setOnClickListener(this);
        TabLayout tabLayout = view.findViewById(R.id.tl_community);
        ViewPager viewPager = view.findViewById(R.id.vp_community);
        viewPager.setAdapter(new PageAdapter(getChildFragmentManager()));
        tabLayout.setupWithViewPager(viewPager);
        view.findViewById(R.id.iv_camera).setOnClickListener(v -> {
            Intent intent = new Intent(getContext(), PostActivity.class);
            intent.putExtra("type", 5);
            startActivity(intent);
        });
        return view;
    }

    /*@Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.cv_search:
                startActivity(new Intent(getContext(), SearchActivity.class));
                break;

            default:
                break;
        }
    }*/
}
